package com.supreme.uploadserver.controller;

import com.alibaba.fastjson.JSONObject;
import com.supreme.commonboot.utils.AjaxResp;
import com.supreme.uploadserver.service.impl.GetReqService;
import com.supreme.uploadserver.service.impl.HttpReqService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "serverUpload")
public class ServerUploadController {

    @GetMapping(value = "testList")
    public AjaxResp swaggerTestList() {
        JSONObject request = new GetReqService().setUrl("http://localhost:7160/api/test/searchAll").request();
        return new AjaxResp(request);
    }

    @PostMapping(value = "simple")
    public AjaxResp simpleServerUpload() {

        JSONObject respResult = new HttpReqService<JSONObject>()
                .uploadReq()
                .setUrl("http://localhost:7150/api/upload/single")
                .addUploadFile("file", "/Users/citecmbp16/Pictures/web_picture/amd1.jpeg")
                .request();

        return new AjaxResp(respResult);
    }
}
